package dao;

import common.spring.jdbc.MySQLHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import pojo.WxUserFormId;

import java.util.List;
import java.util.Map;

/**
 * Created by asus on 2019/1/30.
 */
@Repository
public class WxUserFormIdDao {
    @Autowired
    MySQLHelper sqlHelper;

    public int addWxUserFormId(Map map){
        return sqlHelper.simpleInsert("wx_user_formId",map);
    }
    public List<WxUserFormId> getWxUserFormIdList(String openId){
     StringBuilder stringBuilder=new StringBuilder();
     stringBuilder.append("select * from wx_user_formId  where DATE_SUB(CURDATE(), INTERVAL 6 DAY) <= date(createTime) and openId=? ORDER  by id ASC");
     return sqlHelper.queryForListBean(stringBuilder.toString(),WxUserFormId.class,new Object[]{openId});
    }

    public int deleteWxUserFormId(Long id){
        return sqlHelper.delete("delete from wx_user_formId where id=?",new Object[]{id});
    }
}
